<!doctype html>
<html class="no-js">
<head>
    <!-- 公共head Begin -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="萌宠之家-C2B2C社会化电商平台" />
    <meta name="description" content="《萌宠之家-C2B2C社会化电商平台》是一个基于宠物社区的一站式电商平台。" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0">

    <title>萌宠之家-C2B2C社会化电商平台->运营后台</title>

    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">

    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link rel="icon" type="image/png" href="../statics/img/favicon.png">

    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <link rel="icon" sizes="192x192" href="../statics/img/app-icon72x72@2x.png">

    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Pet Mall"/>
    <link rel="apple-touch-icon-precomposed" href="../statics/img/app-icon72x72@2x.png">

    <!-- Tile icon for Win8 (144x144 + tile color) -->
    <meta name="msapplication-TileImage" content="../statics/img/app-icon72x72@2x.png">
    <meta name="msapplication-TileColor" content="#0e90d2">

    <link rel="stylesheet" href="../statics/AmazeUI/assets/css/amazeui.min.css">
    <link rel="stylesheet" href="../statics/AmazeUI/assets/css/admin.css">
    <link rel="stylesheet" href="../statics/AmazeUI/assets/css/app.css">

    <!--[if (gte IE 9)|!(IE)]><!-->
    <script src="../statics/AmazeUI/assets/js/jquery.min.js"></script>
    <!--<![endif]-->
    <script src="../statics/AmazeUI/assets/js/amazeui.min.js"></script>
    <script src="../statics/AmazeUI/assets/js/amazeui.modal.js"></script>
    <!-- 百度编辑器
    <script type="text/javascript" charset="utf-8" src="../statics/UEditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../statics/UEditor/ueditor.all.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../statics/UEditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript">
        var ue = UE.getEditor('editor',{
                initialFrameWidth:"100%" //初始化选项
                //scaleEnabled:true//scaleEnabled {Boolean} [默认值：false] //是否可以拉伸长高，默认true(当开启时，自动长高失效)
            }
        );
    </script>
     -->
    <script src="../statics/AmazeUI/assets/js/validator.js"></script>
    <script src="../statics/js/plugin/jquery.livequery.js"></script>
    <!-- 此处form的导入和amazeui.min.js会有冲突
    <script src="statics/js/plugin/jquery.form.js"></script>
     -->
    <!--
    <script>
        $().ready( function() {
            AMUI.plugin('mySelected', AMUI.selected);
            $('[data-am-selected]').mySelected({btnWidth: '100%', maxHeight: '200px', btnSize: 'sm', btnStyle: 'secondary'});
        });
    </script>
        -->
    <script src="../statics/js/plugin/jquery.metadata.js"></script>
    <script src="../statics/js/base.js"></script>
    <script src="../statics/js/jquery.lSelect.js"></script>
    <!-- 公共head End -->
</head>
<body>
<div class="admin-content">
    <div class="admin-content-body">
        <div class="am-cf app-padding-title">
            <div class="am-fl am-cf">
                <strong class="am-text-primary am-text-lg">首页</strong> / <small>管理中心</small>
            </div>
        </div>

        <hr data-am-widget="divider" style="" class="am-divider am-divider-dotted am-margin-top-0" />

        <ul class="am-avg-sm-1 am-avg-md-4 am-margin am-padding am-text-center admin-content-list ">
            <li>
                <a href="order_list.html" class="am-text-success"><span class="am-icon-btn am-icon-file-text"></span><br />已完成订单数<br /><strong id="lblCompleteOrderNum" >-</strong></a></li>
            <li><a href="order_list.html" class="am-text-danger"><span class="am-icon-btn am-icon-briefcase"></span><br />等待发货订单数<br /><strong id="lblWaitSendOrderNum" >-</strong></a></li>
            <li><a href="product_list.html" class="am-text-warning"><span class="am-icon-btn am-icon-archive"></span><br />在售宠物总数<br /><strong id="lblOnsalePetNum" >-</strong></a></li>
            <li><a href="member_list.html" class="am-text-primary"><span class="am-icon-btn am-icon-user-md"></span><br />会员总数<br /><strong id="lblUserNum" >-</strong></a></li>
        </ul>

    </div>
</div>
</body>
<script>

    // 首页列表Map
    let indexMap = new Object();

    let jsonUser;
    let token;

    $().ready(function() {

        // 判断用户信息和token是否存在
        jsonUser = sessionStorage.getItem("admin");
        token = sessionStorage.getItem("token");

        if(!jsonUser || !token) {
            top.location.href = 'admin_login.html';
            return;
        }

        // 判断当前页面是否在框架页中，如果不存在，就跳转到后台中心页面
        if(self.location == top.location)
            location.href='admin_center.html';

        // iPhone真机上safari访问时滚动效果会失效，用下面代码进行处理
        //console.info(navigator.userAgent);
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
            //匹配iPhone
            //原始宽度
            let scrollableDivWidth = $(".am-scrollable-horizontal").width();

            //与屏幕宽度对比，设置一个比较小的宽度
            $(".am-scrollable-horizontal").width(screen.width > scrollableDivWidth ? scrollableDivWidth : screen.width);

            //console.info("iPhone");
        }// if();

        // 加载'首页'数据
        loadIndex();

    });// $().ready();

/**	加载'首页'数据 **/
function loadIndex() {

    // 加载'首页'数据
    $.post('http://localhost:8080/index/admin', {token:token}, function (result) {

        // 如果返回的数据的响应码不是'成功(200)'
        if(result.code != 200) {
            Modal.alert(result.msg);
            return;
        }

        // 如果返回的数据响应码为200
        // 就进行表格数据填充
        indexMap = result.data;

        // 已完成订单数
        $('#lblCompleteOrderNum').html(indexMap.completeOrderNum);
        // 等待发货订单数
        $('#lblWaitSendOrderNum').html(indexMap.waitSendOrderNum);
        // 在售宠物数
        $('#lblOnsalePetNum').html(indexMap.onSalePetNum);
        // 会员总数
        $('#lblUserNum').html(indexMap.userNum);

    });// $.post();

}// loadIndex();
</script>
</html>